import request from '../request/reuqest'
import { Iloginmsg } from '../views/login/esType'

// 登录
export function loginAPI (data: Iloginmsg) {
  return request({
    method: 'POST',
    url: '/admin/login',
    data
  })
}

// 注册
export function unloginAPI (data:Iloginmsg ) {
  return request({
    method: 'post',
    url: '/admin/register',
    data
  })
}

// id获取用户信息
export function getUserByIdAPI (id: any) {
  return request({
    method: 'GET',
    url: '/user/getById',
    params: {
      id
    }
  })
}

// 检查用户名
export function existUserNameAPI (name: string | undefined) {
  return request({
    method: 'GET',
    url: '/admin/exist',
    params: {
      username: name
    }
  })
}

// 登出
export function backLoginAPI () {
  return request({
    method: 'GET',
    url: '/admin/logout'
  })
}

// 获取用户状态
export function getStateAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getState',
    params: {
      id
    }
  })
}

// 获取用户创建账号时间
export function getDateAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getDate',
    params: {
      id
    }
  })
}

// 获取用户写的文章
export function getMyBlogAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getMyBlog',
    params: {
      id
    }
  })
}

// 获取用户收藏的文章
export function getMyCollectAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getMyCollect',
    params: {
      id
    }
  })
}

// 获取用户点赞的文章
export function getMyLikeAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getMyLike',
    params: {
      id
    }
  })
}

// 获取用户关注的人
export function getMyFocusAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getMyFocus',
    params: {
      id
    }
  })
}

// 获取用户的粉丝
export function getMyFollowAPI(id: number) {
  return request({
    method: 'GET',
    url: '/user/getMyFollow',
    params: {
      id
    }
  })
}

// 获取用户的粉丝
export function upfile64API(base64: string | null | ArrayBuffer) {
  return request({
    method: 'post',
    url: '/file/upload2',
    data: {
      base64: base64
    }
  })
}

// 关注
export function attentionAPI(focusId: any) {
  return request({
    method: 'post',
    url: '/follow/my/add',
    data: {
      focusId
    }
  })
}

// 取消关注
export function unattentionAPI(focusId: any) {
  return request({
    method: 'delete',
    url: '/follow/my/delete',
    data: {
      focusId
    }
  })
}